package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.MYHozomListEntity;
import com.runen.infinitemovement.tool.GlideUtils;

public class MyHozomAdapter extends BaseQuickAdapter<MYHozomListEntity.DataBean.MissionStatesBean, BaseViewHolder> {
    private Context context;
    private int imgID;

    public OnClickListener getOnClickListener() {
        return onClickListener;
    }

    public void setOnClickListener(OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    private OnClickListener onClickListener;

    public MyHozomAdapter(Context context) {
        super(R.layout.item_my_hozom_1);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MYHozomListEntity.DataBean.MissionStatesBean item) {
        ImageView rci_circle = helper.getView(R.id.rci_circle);
        TextView tv_hz_num = helper.getView(R.id.tv_hz_num);
        TextView tv_title = helper.getView(R.id.tv_title);
        TextView tv_go_for = helper.getView(R.id.tv_go_for);

        tv_title.setText(item.title);
        helper.setText(R.id.tv_description, item.description);
        tv_hz_num.setText("+" + item.tinder + "");
        GlideUtils.loadImage(context, item.iconUrl, rci_circle);
        tv_go_for.setText(item.button);
        if (item.canBeGot) {
            tv_go_for.setBackgroundResource(R.drawable.bg_eb4542_fc6d50_360dp);
            tv_go_for.setEnabled(true);
        } else {
            tv_go_for.setEnabled(false);
            tv_go_for.setBackgroundResource(R.drawable.bg_f6f7fb_360dp);
            tv_go_for.setTextColor(context.getResources().getColor(R.color.color_FF999999));
            tv_go_for.setText("已完成");
        }
        tv_go_for.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClickListener != null) {
                    onClickListener.onClick(item, helper.getAdapterPosition());
                }
            }
        });
    }

    public interface OnClickListener {
        void onClick(MYHozomListEntity.DataBean.MissionStatesBean item, int point);
    }
}
